package leetcode.editor.cn;

/**
 * @author: yangwk
 * @date: 2023/6/6
 * @description:
 **/
public class P746MinCostClimbingStairs {
    public static void main(String[] args) {
        int[] arr = {10, 15, 20};
        System.out.println(minCostClimbingStairs(arr));

    }
    public static int minCostClimbingStairs(int[] cost) {
        //a[i]=min[cost[i-2]+a[i-2],a[[i-1]+cost[i-1]
        int[] arr = new int[cost.length + 1];
        arr[0] = 0;
        arr[1] = 0;
        for (int i = 2; i <= cost.length; i++) {
            arr[i] = Math.min(cost[i - 2] + arr[i - 2], cost[i - 1] + arr[i - 1]);
        }
        return arr[cost.length];
    }
}
